package com.sctvcloud.qingchuan.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;
import com.ruihang.generalibrary.ui.util.OnItemInternalClick;
import com.sctvcloud.qingchuan.R;
import com.sctvcloud.qingchuan.base.BaseFragment;
import com.sctvcloud.qingchuan.beans.PoliticsItem;
import com.sctvcloud.qingchuan.ui.adapter.holder.BaseAbsHolder;
import com.sctvcloud.qingchuan.ui.adapter.holder.PoliticsItemHolder;

import java.util.List;

/**
 * 问政列表数据
 */
public class PoliticsListAdapter extends BaseHolderAbsAdapter<PoliticsItem, BaseAbsHolder<PoliticsItem>> {
    private OnItemInternalClick onItemInternalClick;
    private BaseFragment fragment;


    public PoliticsListAdapter( BaseFragment fragment,Context context, List<PoliticsItem> list ) {
        super(context, list);
        this.fragment = fragment;
    }


    @Override
    public BaseAbsHolder<PoliticsItem> onCreateViewHolder(ViewGroup parent, int viewType) {
        BaseAbsHolder bah;
        LayoutInflater inflater = LayoutInflater.from(context);
        View v = inflater.inflate(R.layout.item_politics_list, parent, false);
        bah = new PoliticsItemHolder(fragment,context, v);
        return bah;
    }

    @Override
    public int getItemViewType(int position) {
        return data.get(position).getDataViewType();
    }

    @Override
    public void onItemInternalClick(View itemView, View view, int position) {
        if (onItemInternalClick != null) {
            onItemInternalClick.onItemInternalClick(itemView, view, position);
        }
    }

    @Override
    public PoliticsListAdapter setItemInternalClick(OnItemInternalClick itemInternalClick) {
        this.onItemInternalClick = itemInternalClick;
        return this;
    }

}
